/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package basic_image_editor.PointOperations.Basic;

import java.awt.image.BufferedImage;

/**
 ************************************************************************************
 * @Author : Gihan Chanuka Karunarathne
 * @Address : 123, R.B.Rathnamalala Road, Eppawala, Anuradhapura, Sri Lanka. 50260
 * @Bsc : Department of Computer Science and Engineering
 *        University of Moratuwa, Sri Lanka
 * Date created : $(date}
 * @Email : gckarunarathne@gmail.com
 * Twitter: https://twitter.com/#!/gihanchanuka
 * LinkedIn: http://lk.linkedin.com/pub/gihan-karunarathne/25/ba3/993
 *************************************************************************************
 */

public class VerticalFlip {
    
    public BufferedImage getVerticalFlip(BufferedImage img) {
        int width = img.getWidth();
        int height = img.getHeight();
        //System.out.println("width: "+width+" "+height);
        BufferedImage tranImg = new BufferedImage(width, height, img.getType());
        //System.out.println(">>width: "+tranImg.getWidth()+" "+tranImg.getHeight());
        for (int i = 0; i < height; i++) {
            //System.out.println("\ni :"+i);
            for (int j = 0; j < width; j++) {
                //System.out.print("j:"+j);
                tranImg.setRGB(width -1 - j, i, img.getRGB(j, i));
                //System.out.println("RGB: "+img.getRGB(j, i));
            }
        }
              
        return tranImg;
    }

}
